home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / win / agrep301.zip / BITLIST.H < prev    next >
C/C++ Source or Header  |  1994-03-01  |  2KB  |  73 lines

  1. /*
  2. //    SCCS Id: "@(#)bitlist.h        (C) Yves Roumazeilles    94/03/01";
  3. //
  4. //    Version: 1.01
  5. */
  6.  
  7. #ifndef    __BITLIST_H__
  8. #define    __BITLIST_H__
  9.  
  10. #ifndef    T_BASE_TYPE
  11. # define    T_BASE_TYPE    unsigned long
  12. #endif
  13. #define    SZ_BASE_TYPE        sizeof(T_BASE_TYPE)
  14. #define    BITS_BASE_TYPE        (SZ_BASE_TYPE*8)
  15. #define    NUM_BASE_ELEM(x)    (x)->Size
  16.  
  17.  
  18. #define    T_BIT_LIST    \
  19.         struct {\
  20.             int            Size;\
  21.             HANDLE            hBits;\
  22.             T_BASE_TYPE FAR*    Bits;\
  23.         }
  24. typedef T_BIT_LIST    BLIST;
  25.  
  26.  
  27.  
  28. /* Basic operations declaration */
  29.  
  30. #define    INDEX_BIT(n)    ((n) / BITS_BASE_TYPE)
  31. #define    MASQUE_BIT(n)    (1L << ((n) % BITS_BASE_TYPE))
  32.  
  33.  
  34. #define    BSET(t, n)    (t).Bits[INDEX_BIT(n)] |= MASQUE_BIT(n)
  35. #define    BCHG(t, n)    (t).Bits[INDEX_BIT(n)] ^= MASQUE_BIT(n)
  36. #define    BCLR(t, n)    (t).Bits[INDEX_BIT(n)] &= ~MASQUE_BIT(n)
  37. #define    BTST(t, n)    ((t).Bits[INDEX_BIT(n)] & MASQUE_BIT(n))
  38.  
  39.  
  40. #ifdef    BITLIST_BUILD
  41. #define    BLCALL    FAR PASCAL
  42. #else
  43. #define    BLCALL    FAR
  44. #endif
  45. extern void BLCALL    BitListDebugOutput(BLIST FAR *x);
  46. extern void BLCALL    BitListClr(BLIST FAR *x);
  47. extern void BLCALL    BitListSet(BLIST FAR *x);
  48. extern void BLCALL    BitListChg(BLIST FAR *x);
  49. extern int BLCALL    BitListCtorClr(BLIST FAR *x, int n);
  50. #define    BitListCtor(x,n)    BitListCtorClr(x,n);
  51. extern int BLCALL    BitListCtorSet(BLIST FAR *x, int n);
  52. extern int BLCALL    BitListEmpty(BLIST FAR *x);
  53. extern void BLCALL    BitListCopy(BLIST FAR *x, BLIST FAR *y);
  54. extern int BLCALL    BitListCopyCtor(BLIST FAR *x, BLIST FAR *y, int n);
  55. extern void BLCALL    BitListLShift(BLIST FAR *x, int n);
  56. extern void BLCALL    BitListRShift(BLIST FAR *x, int n);
  57. extern void BLCALL    BitListOr(BLIST FAR *x, BLIST FAR *y);
  58. extern void BLCALL    BitListCopyOr(BLIST FAR *x, BLIST FAR *y, BLIST FAR *z);
  59. extern void BLCALL    BitListAnd(BLIST FAR *x, BLIST FAR *y);
  60. extern void BLCALL    BitListCopyAnd(BLIST FAR *x, BLIST FAR *y, BLIST FAR *z);
  61. extern void BLCALL    BitListAndNot(BLIST FAR *x, BLIST FAR *y);
  62. extern void BLCALL    BitListOrNot(BLIST FAR *x, BLIST FAR *y);
  63. extern void BLCALL    BitListNot(BLIST FAR *x);
  64. extern void BLCALL    BitListAdd(BLIST FAR *x, BLIST FAR *y);
  65. extern void BLCALL    BitListSub(BLIST FAR *x, BLIST FAR *y);
  66. extern int BLCALL    BitListEqual(BLIST FAR *x, BLIST FAR *y);
  67. extern int BLCALL    BitListEqualZero(BLIST FAR *x);
  68. extern int BLCALL    BitListCompare(BLIST FAR *x, BLIST FAR *y);
  69. extern int BLCALL    BitListLock(BLIST FAR *x);
  70. extern int BLCALL    BitListUnlock(BLIST FAR *x);
  71.  
  72. #endif    /* __BITLIST_H__ */
  73.